package com.heima.article.listener;

import com.alibaba.fastjson.JSON;
import com.heima.article.dto.ArticleStreamMessage;
import com.heima.article.service.IApArticleService;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;

public class ListenrtStream {
    @Autowired
    IApArticleService service;
    @KafkaListener(topics = {"article_behavior"})
    public void listenerStream(ConsumerRecord<String,String> record){

        String value = record.value();
        //ArticleStreamMessage
        ArticleStreamMessage articleStreamMessage = JSON.parseObject(value, ArticleStreamMessage.class);
        service.updateRedOrMy(articleStreamMessage);
    }
}
